package com.demos.diveinspring.service.impl;

import com.demos.diveinspring.service.CalculateService;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

/**
 * 条件装配注解 @Profile ： 主要当条件满足的时候才会加载装配这个bean
 * 这里的条件就是Java7
 */
@Profile("Java7")
@Service
public class Java7CalculateServiceImpl implements CalculateService {
    @Override
    public Integer sum(Integer... values) {
        System.out.println("Java7 方式实现");
        int sum = 0;
        for (int i = 0; i < values.length; i++) {
            sum += values[i];
        }
        return sum;
    }
}
